package leetcode.动态规划.middle;

import java.util.Arrays;

/**
 * @author wangmaolin1
 * @date 2023/11/15 22:02
 */
public class _435 {
    public static int eraseOverlapIntervals(int[][] intervals) {
        Arrays.sort(intervals,(a,b)->{
            if (a[1]>b[1]){
                return 1;
            }else if (a[1]<b[1]){
                return -1;
            }
            return 0;
        });
        int minEnd = intervals[0][1];
        int num=1;
        for (int i = 1; i < intervals.length; i++) {
            int[] interval = intervals[i];
            if (interval[0]>=minEnd){
                minEnd=interval[1];
                num++;
            }
        }
        return  num;
    }

    public static void main(String[] args) {
        //[[-2147483646,-2147483645],[2147483646,2147483647]]
        int i = eraseOverlapIntervals(new int[][]{{-2147483646, -2147483645}, {2147483646, 2147483647}});
        System.out.println(i);
    }
}
